package com.wk.code.wkserver.controller.admin;

import com.wk.code.wkserver.entity.SysBanner;
import com.wk.code.wkserver.request.admin.SysBannerRequest;
import com.wk.code.wkserver.response.result.R;
import com.wk.code.wkserver.service.ISysBannerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author wq
 * @version 1.0
 * @date 2021/06/15 14:44
 */
@RestController
@RequestMapping("admin/banner")
@AllArgsConstructor
@Api(tags = "admin-后台广告管理")
public class AdminBannerController {

    private final ISysBannerService sysBannerService;

    /**
     * 添加
     *
     * @param request 请求参数
     * @return R
     */
    @ApiOperation(value = "添加")
    @PostMapping("/add")
    public R add(@RequestBody SysBannerRequest request) {
        sysBannerService.add(request);
        return R.success();
    }

    /**
     * 更新
     *
     * @param request 请求参数
     * @return R
     */
    @ApiOperation(value = "更新")
    @PostMapping("/update")
    public R update(@RequestBody SysBannerRequest request) {
        sysBannerService.update(request);
        return R.success();
    }

    /**
     * 删除
     *
     * @param id ID
     * @return R
     */
    @ApiOperation(value = "删除")
    @GetMapping("/delete")
    public R delete(Integer id) {
        sysBannerService.delete(id);
        return R.success();
    }

    /**
     * 详情
     *
     * @param id ID
     * @return R
     */
    @ApiOperation(value = "详情")
    @GetMapping("/detail")
    private R detail(Integer id) {
        return R.success(sysBannerService.detail(id));
    }


    /**
     * 分页
     *
     * @param request 请求参数
     * @return R
     */
    @ApiOperation(value = "分页")
    @PostMapping("/page")
    private R page(@RequestBody SysBannerRequest request) {
        return R.success(sysBannerService.page(request));
    }


}
